﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace CollisionDetectionSandbox
{
    class CreditsScreen : Screen
    {
        Texture2D mCreditsScreenBackground;
        Button mBackButton, mQuitButton, mBackHover, mQuitHover;
        public static int count;
       

         public CreditsScreen(ContentManager theContent, EventHandler theScreenEvent)
            : base(theScreenEvent)
        {
            //Load the background texture for the screen
            mCreditsScreenBackground = theContent.Load<Texture2D>("Main Textures/CreditScreenEdit");
            mBackButton = new Button(theContent, "ButtonTextures/button_menu2", ZeusGame.xpos - 100, ZeusGame.ypos + 250);
            mQuitButton = new Button(theContent, "ButtonTextures/button_quit2", ZeusGame.xpos + 100, ZeusGame.ypos + 250);
            mBackHover = new Button(theContent, "ButtonTextures/buttonhover_menu2", ZeusGame.xpos - 100, ZeusGame.ypos + 250);
            mQuitHover = new Button(theContent, "ButtonTextures/buttonhover_quit2", ZeusGame.xpos + 100, ZeusGame.ypos + 250);
        }

         public override void Update(GameTime theTime)
         {
             MouseState state = Mouse.GetState();
             int mx = state.X;
             int my = state.Y;

             if (state.LeftButton == ButtonState.Pressed)
             {                 
                 if (mBackButton.hit_image(mx, my))
                 {
                     count = 1;
                     ScreenEvent.Invoke(this, new EventArgs());
                 }
                 else if (mQuitButton.hit_image(mx, my))
                 {
                     count = 2;
                     ScreenEvent.Invoke(this, new EventArgs());
                 }
             }
             base.Update(theTime);
         }

         public override void Draw(SpriteBatch theBatch)
         {
             MouseState state = Mouse.GetState();
             int mx = state.X;
             int my = state.Y;

             theBatch.Draw(mCreditsScreenBackground, Vector2.Zero, Color.White);
             if (mBackButton.hit_image(mx, my))
             {
                 mBackHover.Draw(theBatch);
             }
             else mBackButton.Draw(theBatch);

             if (mQuitButton.hit_image(mx, my))
             {
                 mQuitHover.Draw(theBatch);
             }
             else mQuitButton.Draw(theBatch);

             base.Draw(theBatch);
         }
    }
}
